package study.springcloud.hystrix.controller;

import cn.hutool.core.thread.ThreadUtil;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.eggs.result.Result;
import study.eggs.result.Results;

import java.util.concurrent.TimeUnit;

@Slf4j
@RestController
public class _04_ThreadPoolController {

    @HystrixCommand
    @RequestMapping("/thread_pool")
    public Result threadPool(long timeout) {
        log.info("starting...");
        ThreadUtil.sleep(timeout, TimeUnit.SECONDS);
        log.info("finishing...");
        return Results.ok();
    }
}
